<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Admin
 *
 * @author lucas
 */
class MY_Controller extends CI_Controller {

    protected $site_redirect = null;

    public function __construct() {
        parent::__construct();
        $this->site_redirect = $this->uri->segment_array();

        /* if( $this->site_redirect[1] != 'adm' AND $this->site_redirect[1] != 'site' ) {
          redirect( base_adm( 'login/login/index' ) );
          } */

        $this->parser->set_js('js/jquery-1.8.2.min.js');
        $this->_load_configuracoes_db();
    }

    private function _load_configuracoes_db() {
        $this->load->model('configuracoes/configuracoes_model');
        $params = array();
        $b_consultar = $this->configuracoes_model->consultar($params);
        foreach ($b_consultar as $key => $value) {
            $this->config->set_item(url_title($value->label, '_', TRUE), $this->_tipo($value->tipo, $value->valor));
        }
    }

    public function _tipo($tipo, $valor = NULL) {
        switch ($tipo) {
            case 'int' :
                return (int) $valor;
                break;

            case 'boolean' :
                return (boolean) $valor;
                break;

            case 'float' :
                return (float) $valor;
                break;

            default :
                return ($valor == NULL ? NULL : (string) $valor);
                break;
        }
    }

}
